export class ScorePanel {
	score: number = 0;
	level: number = 0;
	scoreEle: HTMLElement;
	levelEle: HTMLElement;

	maxLevel: number;
	unScore: number;
	constructor(maxLevel: number = 10, unScore: number = 2) {
		this.maxLevel = maxLevel
		this.unScore = unScore

		this.scoreEle = document.getElementById('score') as HTMLElement;
		this.levelEle = document.getElementById('level') as HTMLElement;
	}

	// 设置加分方法
	addScore() {
		this.score++;
		this.scoreEle.innerHTML = this.score + '';
		if (this.score % this.unScore == 0) {
			this.levelUp()
		}
	}
	levelUp() {
		if (this.level < this.maxLevel) {
			this.levelEle.innerHTML = ++this.level + ''
		}
	}

}
export default ScorePanel;